import cv2
image=cv2.imread('hat.png',cv2.IMREAD_GRAYSCALE)
cv2.imshow("Input",image)
kerne1=cv2.getStructuringElement(cv2.MORPH_RECT,(5,5))
image1=cv2.erode(image,kerne1)
image2=cv2.dilate(image,kerne1)
cv2.imshow("Output",image2)
cv2.waitKey()
cv2.destroyAllWindows()